package com.hsylient.javase.draftpaper;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

@Slf4j
public class OutOfMemoryTest {

    private static final List<byte[]> list = new ArrayList<>();

    public static void main(String[] args) throws InterruptedException {
        while (true) {
            byte[] bytes = new byte[1000 * 1000]; // 1KB= 1024bytes 1MB = 1024 KB = 1024 * 1024 bytes
            list.add(bytes);
            Thread.sleep(10000);
            log.info("[测试OOM] 内存占用大小 {}MB", list.size());
        }
    }
}